import setting from "@/setting";
import { getconfig } from '@/api/system';
import useUserStore from '@/store/user';

export default function getPageTitle(pageTitle: string): string {
  const userStore = useUserStore()
  if (userStore.token) {
    getconfig({ config_name: 'systemInfo' }).then(res => {
      if (res.state == 200) {
        let content = JSON.parse(res.data.config_content)
        setting.title = content.title || '嘉潮汇'
        var link = document.querySelector('link[rel="icon"]');
        link.href = content.machine_logo
      }
    })
  }
  if (pageTitle) {
    // ${pageTitle} - 
    return `${setting.title}`
  }
  return `${setting.title}`
}
